<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Django's Bacon Lanches</title>
        <link href="http://localhost/bdii/template/style/template.css" rel="stylesheet" type="text/css" />
        <link href="http://localhost/bdii/template/style/jquery-ui-1.9.0.custom.min.css" rel="stylesheet" type="text/css" />
        <script src="http://localhost/bdii/template/script/jquery-1.8.2.js" language="javascript" type="text/javascript"></script>
        <script src="http://localhost/bdii/template/script/jquery-ui-1.9.0.custom.min.js" language="javascript" type="text/javascript"></script>
        <script src="http://localhost/bdii/template/script/functions.js" language="javascript" type="text/javascript"></script>
    </head>

    <body>
        <div id="main">
            <div id="wrapper">
                <div id="header">
                    <a href="#"><img src="http://localhost/bdii/template/images/logo.png" border="0" /></a>
                </div>
                <div id="container">
                    <div id="sidebar">
                        <h3>Carrinho</h3>
                        <table>
                            <thead>
                                <tr>
                                    <td>Item</td>
                                    <td>Qtd</td>
                                    <td>Valor</td>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                if (!isset($_SESSION))
                                    session_start();
                                $total = 0;
                                $taxa = "3,00";
                                $cont = 0;
                                if (isset($_SESSION['cart'])) {
                                    $produtos = unserialize($_SESSION['cart']);
                                    $cont = count($produtos);
                                    if ($cont >= 2)
                                        $taxa = "0,00";
                                    foreach ($produtos as $produto) :
                                        $total += $produto->getPreco();
                                        ?>
                                        <tr>
                                            <td><?= $produto->getNome(); ?></td>
                                            <td><?= 1 ?></td>
                                            <td><?= number_format($produto->getPreco(), 2, ',', '.'); ?></td>
                                        </tr>
                                        <?php
                                    endforeach;
                                }
                                ?>
                            </tbody>
                        </table>
                        <div id="sidebar-bottom">
                            <span class="cell_1">Taxa de entrega: </span>
                            <span class="currency">R$</span>
                            <span class="cell_2"><?= $taxa ?>*</span><br />
                            <span class="cell_1">Total: </span>
                            <span class="currency">R$</span>
                            <span class="cell_2"><?= number_format($total, 2, ',', '.'); ?></span>
                            <span style="float: left;">*Grátis acima de 2 unidades</span>
                            <br />
                            <br />
                            <?php
                            if (!isset($_SESSION))
                                session_start();
                            if (!isset($_SESSION['usuario'])):
                                ?>
                                <a href="http://localhost/bdii/index.php/Bacon/login">Área do cliente</a>
                                <a href="http://localhost/bdii/index.php/Bacon/cadastrarUsuario">Cadastre-se</a>
                                <?php
                            else:
                                $usuario = unserialize($_SESSION['usuario']);
                                if ($usuario->getIdPermissao() == 1) :
                                    ?>
                                    <a href="http://localhost/bdii/index.php/Bacon/cadastroProduto">Cadastrar Lanches</a>
                                    <a href="http://localhost/bdii/index.php/Bacon/listarPedidos">Visualizar Pedidos</a>

                                <?php else: ?>
                                    <a href="http://localhost/bdii/index.php/Bacon/atualizarCadastro">Atualizar Cadastro</a>
                                <?php
                                endif;
                                ?>
                                <a href="http://localhost/bdii/index.php/Bacon/logout">Sair</a>
                            <?
                            endif;
                            if ($cont > 0):
                                ?>
                                <a href="http://localhost/bdii/index.php/Bacon/limparCart">Limpar</a>
                                <a href="http://localhost/bdii/index.php/Bacon/fecharPedido">Fechar Pedido</a>
                            <?php endif; ?>
                        </div>
                    </div>
                    <div id="menu">
                        <ul>
                            <li><a href="http://localhost/bdii/index.php">Home</a></li>
                            <li><a href="#">Lanches</a></li>
                            <li><a href="#">Promoções</a></li>
                            <li><a href="#">Bebidas</a></li>
                            <li><a href="#">Porções</a></li>
                        </ul>
                    </div>
                    <div id="content">